from page.base_page import BasePage
from appium.webdriver.common.appiumby import AppiumBy as By
class SearchContent(BasePage):
    """收缩添加内容页面"""
    #定位器
    search_locator=(By.ID,"com.xiachufang:id/search_edit_text")
    click_search_locator = (By.XPATH, '//android.widget.TextView[@text="搜索"]')
    one_naem_locator=(By.XPATH,'//android.widget.TextView[@resource-id="com.xiachufang:id/common_first_text" and @text="可乐鸡翅"]')
    one_recipe_locator=(By.ID,"com.xiachufang:id/common_photo_image_view")
    result_name_locator=(By.ID,"com.xiachufang:id/tv_load_status_major")
    def search_content(self,content):
        """搜索内容"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.search_locator).send_keys(content)
    def click_search(self):
        """点击搜索"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.click_search_locator).click()
    def one_name(self):
        return self.find_element(self.one_naem_locator).text
    def click_one_recipe(self):
        """点击搜索结果第一个菜谱"""
        bp = BasePage(self.driver)
        bp.show_waiting(self.driver, self.one_recipe_locator).click()
    def result_name(self):
        """返回搜索结果的文本"""
        bp = BasePage(self.driver)
        return bp.show_waiting(self.driver, self.result_name_locator).text